#include"SeqList.h"

void TestSeqList1()
{
	SL s1;
	SeqListInit(&s1);
	SeqListPushBack(&s1, 1);		//尾插
	SeqListPushBack(&s1, 2);
	SeqListPushBack(&s1, 3);
	SeqListPushBack(&s1, 4);
	SeqListPushBack(&s1, 5);

	//SeqListPopBack(&s1);               //尾删
	//SeqListPopBack(&s1);
	//SeqListPopBack(&s1);
	//SeqListPopBack(&s1);
	//SeqListPopBack(&s1);
	//SeqListPopBack(&s1);
	//SeqListPopBack(&s1);


	SeqListPushFront(&s1, 10); //头插
	SeqListPushFront(&s1, 20);
	SeqListPushFront(&s1, 30);
	SeqListPushFront(&s1, 40);
	SeqListPushFront(&s1, 50);

	SeqListPopFront(&s1);               //头删
	SeqListPopFront(&s1);              

	int pos = SeqListFind(&s1, 20);   //查找
	if (pos != -1)
	{
		SeqListErase(&s1, pos);
	}
	SeqListInsert(&s1, 2, 20);  //指定下标位置插入(在下标为2的下面插入20)

	

	SeqListPrint(&s1);   //打印接口
	SeqListDestory(&s1);  //销毁顺序表

	
}

void TestSeqList2()
{
	SL s1;
	SeqListInit(&s1);

	SeqListPushFront(&s1, 100); //头插
	SeqListPushFront(&s1, 200);
	SeqListPushFront(&s1, 300);
	SeqListPushFront(&s1, 400);
	SeqListPushFront(&s1, 500);

	SeqListPushBack(&s1, 11);		//尾插
	SeqListPushBack(&s1, 21);
	SeqListPushBack(&s1, 31);
	SeqListPushBack(&s1, 41);
	SeqListPushBack(&s1, 51);

	SeqListPrint(&s1);   //打印接口
	SeqListDestory(&s1);  //销毁顺序表
}


void TestSeqList3()
{
	SL s1;
	SeqListInit(&s1);
	SeqListInsert(&s1, 0, 100);
	SeqListInsert(&s1, 0, 200);
	SeqListInsert(&s1, 0, 300);
	SeqListInsert(&s1, 0, 400);
	SeqListInsert(&s1, 0, 500);

	SeqListInsert(&s1, 5, 11);
	SeqListInsert(&s1, 6, 21);
	SeqListInsert(&s1, 7, 31);
	SeqListInsert(&s1, 8, 41);
	SeqListInsert(&s1, 9, 51);

	//SeqListErase(&s1, 3);  //删除指定下标位置
	SeqListPopFront(&s1);               //头删



	SeqListPrint(&s1);   //打印接口
	SeqListDestory(&s1);  //销毁顺序表

}

int main()
{
	//TestSeqList1();
	TestSeqList2();  //将头插与尾插归纳为插入
  //TestSeqList3();

	return 0;
}
